package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-03-01 22:20
 **/
public class LeetCode2186 {

    public int minSteps(String s, String t) {
        int[] letters1 = new int[26];
        int[] letters2 = new int[26];
        int m = s.length();
        int n = t.length();
        for (int i = 0; i < m; i++) {
            ++letters1[s.charAt(i) - 'a'];
        }
        for (int i = 0; i < n; i++) {
            ++letters2[t.charAt(i) - 'a'];
        }
        //最大相同数
        int max = 0;
        for (int i = 0; i < 26; i++) {
            max += Math.min(letters1[i], letters2[i]);
        }
        return m + n - 2 * max;
    }

}
